/**   
 * 项目名：phms3
 * 日期：    2019-11-23 11:17:07  
 * Copyright (c) 2015- HTSC-版权所有     
 */

package com.joysuch.wwyt.core.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "WWYT_BASE_ORGANIZATION")
@SQLDelete(sql = "update WWYT_BASE_ORGANIZATION set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BASE_ORGANIZATION set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")

public class BaseOrganization implements java.io.Serializable {

    // columns START
    // ID
    private java.lang.Long id;
    // 名称
    private java.lang.String name;
    // 租户
    private java.lang.Long tenentId;
    // 代码
    private java.lang.String code;
    // 类型
    private java.lang.String type;
    // 父组织ID
    private java.lang.Long parentId;
    // 顺序
    private java.lang.Integer showOrder;
    // 备注
    private java.lang.String remark;
    // 负责人ID
    private java.lang.Long chiefId;
    // 创建人
    private java.lang.Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private java.lang.Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private java.lang.String deleteFlag;
    // 组织机构代码
    private java.lang.String orgCode;
    // columns END

    public void setId(java.lang.Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public java.lang.Long getId() {
        return this.id;
    }

    @Column(name = "NAME", length = 50)
    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String value) {
        this.name = value;
    }

    @Column(name = "TENENT_ID")
    public java.lang.Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(java.lang.Long value) {
        this.tenentId = value;
    }

    @Column(name = "CODE", length = 100)
    public java.lang.String getCode() {
        return this.code;
    }

    public void setCode(java.lang.String value) {
        this.code = value;
    }

    @Column(name = "TYPE", length = 10, nullable = false)
    public java.lang.String getType() {
        return this.type;
    }

    public void setType(java.lang.String value) {
        this.type = value;
    }

    @Column(name = "PARENT_ID")
    public java.lang.Long getParentId() {
        return this.parentId;
    }

    public void setParentId(java.lang.Long value) {
        this.parentId = value;
    }

    @Column(name = "SHOW_ORDER")
    public java.lang.Integer getShowOrder() {
        return this.showOrder;
    }

    public void setShowOrder(java.lang.Integer value) {
        this.showOrder = value;
    }

    @Column(name = "REMARK", length = 500)
    public java.lang.String getRemark() {
        return this.remark;
    }

    public void setRemark(java.lang.String value) {
        this.remark = value;
    }

    @Column(name = "CHIEF_ID")
    public java.lang.Long getChiefId() {
        return this.chiefId;
    }

    public void setChiefId(java.lang.Long value) {
        this.chiefId = value;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public java.lang.Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(java.lang.Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public java.lang.Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(java.lang.Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public java.lang.String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(java.lang.String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public java.lang.String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(java.lang.String value) {
        this.orgCode = value;
    }

    private Set<BaseOrganization> baseOrganizations = new LinkedHashSet<>(0);

    @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
    @JoinColumn(name = "PARENT_ID")
    public Set<BaseOrganization> getBaseOrganizations() {
        return this.baseOrganizations;
    }

    public void setBaseOrganizations(Set<BaseOrganization> baseOrganizations) {
        this.baseOrganizations = baseOrganizations;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
                .append("tenentId", getTenentId()).append("code", getCode()).append("type", getType())
                .append("parentId", getParentId()).append("showOrder", getShowOrder()).append("remark", getRemark())
                .append("chiefId", getChiefId()).append("createBy", getCreateBy()).append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime())
                .append("deleteFlag", getDeleteFlag()).append("orgCode", getOrgCode()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BaseOrganization == false)
            return false;
        if (this == obj)
            return true;
        BaseOrganization other = (BaseOrganization) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
